package com.ht.controller;

import com.ht.data.Result;
import com.ht.domain.bo.MyDoctorBO;
import com.ht.domain.vo.MyDoctorVO;
import com.ht.feign.AppointmentRegisteredFeign;
import com.ht.feign.PublicOutpatientFeign;
import com.ht.service.MyDoctorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController  //等于@Restquest + @Controller
@RequestMapping("/privateDoctors")
@Api("快速问医生管理系统")
@RefreshScope  //实时刷新
public class PrivateDoctorsController {

    @Autowired
    private PublicOutpatientFeign publicOutpatientFeign;

    @Autowired
    private AppointmentRegisteredFeign appointmentRegisteredFeign;

    @Autowired
    private MyDoctorService myDoctorService;


    @PostMapping("/querypartment")
    @ApiOperation("查询所有科室")
    @ApiImplicitParam()
    public Result querypartment(){
        Result all = publicOutpatientFeign.findDepartmentAll();
        return all;
    }


    /**
     *
     * @param  departmentId //状态 也就是科室对应的id
     * @param  status //状态 0/综合排序/  1/价格由高到低 2/价格由低到到
     * @param  score //状态 也就是科室对应的id
     * @return
     */
    @PostMapping("/queryCharges/{departmentId}/{status}/{score}")
    @ApiOperation("根据科室id查询相对应的医生")
    @ApiImplicitParam()
    public Result queryDepartment(@PathVariable("departmentId") Long departmentId,@PathVariable("status")Integer status,@PathVariable("score")Long score){
        Result result = appointmentRegisteredFeign.queryDoctorBydepartmentIdAndStatus(departmentId,status,0L,score);
        return result;
    }

    @PostMapping("/serviceDetails/{id}")
    @ApiOperation("根据医生id添加私人医生")
    @ApiImplicitParam()
    public Result serviceDetails(@PathVariable("id")Long id,Integer price,Integer time){
        MyDoctorBO bo = myDoctorService.serviceDetails(id, price, time);
        MyDoctorVO vo = new MyDoctorVO();
        BeanUtils.copyProperties(bo,vo);
        return Result.OK().setData(vo);
    }
}
